package com.david.common.utils;

import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;

import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;

public class ResultUtils implements Serializable {
    public static ResponseEntity<Object> success(Boolean code, Object data) {
        Map<String, Object> map = new HashMap<>(4);
        map.put("success", code);
        map.put("data", data);
        return new ResponseEntity<>(map, HttpStatus.OK);
    }

    public static ResponseEntity<Object> fail(Boolean code, String msg) {
        Map<String, Object> map = new HashMap<>(4);
        map.put("success", code);
        map.put("msg", msg);
        return new ResponseEntity<>(map, HttpStatus.OK);
    }
}
